home *** CD-ROM | disk | FTP | other *** search
/ Biodiversity of Illinois 2: Woodland Habitats / Biodiversity of Illinois 2 - Woodland Habitats.iso / mac / casts / PDFxtraBehaviors.cst / 00006_Script_PDF_Save < prev    next >
Text File  |  2006-07-11  |  4KB  |  104 lines

  1. -- Save
  2.  
  3. Property pEvent, pSprite, pFileName, pPathType, pAlertFlag
  4.  
  5. on doSave me
  6.   if(pFileName="") then
  7.     set err = PDF_Save(sprite pSprite, "")
  8.   else
  9.     case pPathType of:
  10.       "Absolute or URL": set fName = pFileName
  11.       "Relative to Movie": set fName = the moviePath & pFileName
  12.     end case
  13.     set err = PDF_Save(sprite pSprite, fName)
  14.   end if
  15.   if PDF_status(sprite pSprite) then alert "PDF Behavior Error"&RETURN&PDF_error(sprite pSprite)
  16. end doSave
  17.  
  18. on mouseUp me
  19.   if (pEvent = #mouseUp) then doSave(me)
  20. end mouseUp
  21.  
  22. on mouseDown me
  23.   if (pEvent = #mouseDown) then doSave(me)
  24. end mouseDown
  25.  
  26. -- standard behavior stuff --
  27. on getPropertyDescriptionList me
  28.   set defaultValues = GetDefaultValues (me)
  29.   
  30.   set pdfSpriteList = getProp (defaultValues, #spriteList)
  31.   set defSprite     = getProp (defaultValues, #defaultSprite)
  32.   if (defSprite=0) then 
  33.     if the ticks - pAlertFlag > 10 then
  34.       alert "Please create a sprite of type PDF first."
  35.     end if
  36.     set pAlertFlag = the ticks -- The ticks when the user clicked "OK"
  37.     
  38.     exit
  39.   end if
  40.   set p_list = [:]
  41.   addprop p_list, #pEvent, [ #comment: "Event", #format:#symbol, #range:[#mouseUp,#mouseDown], #default:#mouseUp]
  42.   addprop p_list, #pSprite, [ #comment: "PDF Sprite is in channel:", #format:#symbol, #range:pdfSpriteList, #default:defSprite]
  43.   addprop p_list, #pFileName, [ #comment: "Save As (File Name):", #format:#string, #default:"" ]
  44.   addprop p_list, #pPathType, [ #comment: "Path is:", #format: #symbol,#range: [ "Absolute or URL", "Relative to Movie"],#default: "Relative to Movie" ]
  45.   return p_list
  46. end
  47.  
  48. on getBehaviorDescription
  49.   tmp = "Save PDF document, optionally as a new file. If File Name is empty, the current PDF document is modified. Otherwise, it is saved under the new file name." 
  50.   tmp = tmp & RETURN& "Available for Windows only, with full version of Acrobat"
  51.   tmp = tmp &RETURN&RETURN& "--- PARAMETERS ---"  
  52.   tmp = tmp & RETURN& "Event: mouseUp or mouseDown."
  53.   tmp = tmp & RETURN& "PDF Sprite is in channel: which channel contains the PDF Sprite"
  54.   tmp = tmp & RETURN& "SaveAs (File Name): string containing the full or relative path and file name to save to."
  55.   tmp = tmp & RETURN& "Path is: Absolute or URL, Relative to movie, Relative to playback engine."
  56.   tmp = tmp &RETURN&RETURN& "Free to use and abuse. (c)1999, Integration New Media, Inc."  &RETURN& "Thanks to James Newton for his suggestions"  
  57.   return tmp  
  58. end
  59.  
  60. on getBehaviorTooltip
  61.   return "Save PDF document, optionally as a new file." &RETURN&  "If File Name is empty, the current PDF document is modified." &RETURN& "Otherwise, it is saved under the new file name." & RETURN&  "Available for Windows only, with full version of Acrobat" 
  62. end
  63.  
  64. -- utils --
  65. on GetDefaultValues me
  66.   if the currentSpriteNum then
  67.     set spriteList = GetSpriteList (me #PDF)
  68.     if count (spriteList) then
  69.       set defaultSprite = getAt (spriteList, 1)
  70.     else
  71.       set defaultSprite = 0
  72.     end if
  73.     
  74.     return [#spriteList: spriteList, #defaultSprite: defaultSprite]
  75.     
  76.   else -- the currentSpriteNum = 0
  77.     -- Director is merely recompiling this script: return dummy values
  78.     return [#spriteList: [1], #defaultSprite: 1]
  79.   end if
  80. end 
  81.  
  82.  
  83. on GetSpriteList me, memberType
  84.   -- return list of sprites of type memberType in current frame
  85.   global version
  86.   if (char 1 of version = 6) then
  87.     set maxSprite = 120
  88.   else
  89.     set maxSprite = the lastChannel
  90.   end if
  91.   
  92.   set aList=[]
  93.   
  94.   repeat with i = 1 to maxSprite
  95.     set spriteMember = the member of sprite i
  96.     -- if (string(m) contains "member 0") then next repeat -- unnecessary
  97.     if (the type of spriteMember = memberType) then -- (JN) Line break
  98.       append (aList, i)
  99.     end if
  100.   end repeat
  101.   
  102.   return aList
  103. end GetSpriteList
  104.